#!/usr/bin/env python
from math import *

def distance(x1, y1, x2, y2):
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))

def direction(x1, y1, x2, y2, radials):
    if x2 - x1 != 0:
        hk = float(atan(-float(float(y2 - y1) / float(x2 - x1))))
        if x1 > x2:
            hk += pi
    else:
        if y1 < y2:
            hk = -pi / 2
        else:
            hk = pi / 2
    
    if radials:
        return hk
    else:
        return hk * float(180)/pi
